﻿Imports Common

Public Class player
    Private _dc As New LOKDBDataContext
    Private ReadOnly Property DC As LOKDBDataContext
        Get
            _dc.DeferredLoadingEnabled = False
            Return _dc
        End Get
    End Property


    'CRUD
    Public Sub Create()

    End Sub

    Public Function [Get](id As Integer) As playerDTO
        Dim PlayerData As tblUser = DC.tblUsers.FirstOrDefault(Function(U) U.intUserID.Equals(id))
        Dim PlayerDTO As playerDTO = PlayerParser.Get(PlayerData)

        Return PlayerDTO
    End Function

    Public Function [Get](username As String, password As String) As playerDTO
        Dim PlayerData As tblUser = DC.tblUsers.FirstOrDefault(Function(U) U.strUsername.Equals(username) AndAlso U.strPassword.Equals(password))
        Dim PlayerDTO As New playerDTO
        If PlayerData Is Nothing Then
            PlayerDTO = New playerDTO("Invalid Login")
            Return PlayerDTO
        End If
        PlayerDTO = PlayerParser.Get(PlayerData)

        Return PlayerDTO
    End Function

    Public Sub Update()

    End Sub

    Public Sub Delete()

    End Sub
End Class
